/**
 Copyright will be fixed soon.
 Author: Hiroshi Ota.
 $Date: $
 $Revision: $
*/

#include "Motor.h"

#ifndef _BRICKOS_

Motor::Motor(const Port port, ISimulatorControl* sc, char* name)
:simCon(sc), myPort(port)
{
	if (sc!=0&&name!=0) {
		sc->setMotorName(port,name);
	}
}


const void Motor::speed(const unsigned char speed) const
{
	if (simCon!=0){
		simCon->orderMotor(myPort, "speed", speed);
	}
}

const void Motor::direction(const MotorDirection dir) const
{
	if (simCon!=0){
		simCon->orderMotor(myPort, "direction", dir);
	}
}

const void Motor::forward() const
{
	if (simCon!=0){
		simCon->orderMotor(myPort, "forward");
	}
}

const void Motor::brake() const
{
	if (simCon!=0){
		simCon->orderMotor(myPort, "brake");
	}
}

const void Motor::brake(int duration) const
{
	if (simCon!=0){
		simCon->orderMotor(myPort, "brake", duration);
	}
}

const void Motor::off() const
{
	if (simCon!=0){
		simCon->orderMotor(myPort, "off");
	}
}

#endif  // _BRICKOS_
